#include "widget.h"
#include "ui_widget.h"
#include <QHBoxLayout>
#include <QPushButton>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    QHBoxLayout* layout = new QHBoxLayout();
    // 创建出两个按钮
    QPushButton* button1 = new QPushButton("按钮1");
    QPushButton* button2 = new QPushButton("按钮2");
    // 创建一个SPacer，让两个按钮之间存在空白
    QSpacerItem* spacer = new QSpacerItem(200, 20); // 需要指定宽度和高度
    layout->addWidget(button1);
    // 将spacer加入layout中
    layout->addSpacerItem(spacer);
    layout->addWidget(button2);
    this->setLayout(layout);
}

Widget::~Widget()
{
    delete ui;
}

